package com.infocollect.project.grant.service.impl;

import java.util.List;
import com.infocollect.common.utils.DateUtils;
import com.infocollect.common.utils.ServletUtils;
import com.infocollect.framework.security.LoginUser;
import com.infocollect.framework.security.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.infocollect.project.grant.mapper.GrSceneMapper;
import com.infocollect.project.grant.domain.GrScene;
import com.infocollect.project.grant.service.IGrSceneService;

/**
 * 签到场次Service业务层处理
 * 
 * @author infocollect
 * @date 2022-05-14
 */
@Service
public class GrSceneServiceImpl implements IGrSceneService 
{
    @Autowired
    private GrSceneMapper grSceneMapper;
    @Autowired
    private TokenService tokenService;

    /**
     * 查询签到场次
     * 
     * @param id 签到场次ID
     * @return 签到场次
     */
    @Override
    public GrScene selectGrSceneById(Long id)
    {
        return grSceneMapper.selectGrSceneById(id);
    }

    /**
     * 查询签到场次列表
     * 
     * @param grScene 签到场次
     * @return 签到场次
     */
    @Override
    public List<GrScene> selectGrSceneList(GrScene grScene)
    {
        return grSceneMapper.selectGrSceneList(grScene);
    }

    /**
     * 新增签到场次
     * 
     * @param grScene 签到场次
     * @return 结果
     */
    @Override
    public int insertGrScene(GrScene grScene)
    {
        grScene.setCreateTime(DateUtils.getNowDate());
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        grScene.setCreateUser(loginUser.getUserName());
        return grSceneMapper.insertGrScene(grScene);
    }

    /**
     * 修改签到场次
     * 
     * @param grScene 签到场次
     * @return 结果
     */
    @Override
    public int updateGrScene(GrScene grScene)
    {
        grScene.setUpdateTime(DateUtils.getNowDate());
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        grScene.setUpdateBy(loginUser.getUserName());
        return grSceneMapper.updateGrScene(grScene);
    }

    /**
     * 批量删除签到场次
     * 
     * @param ids 需要删除的签到场次ID
     * @return 结果
     */
    @Override
    public int deleteGrSceneByIds(Long[] ids)
    {
        return grSceneMapper.deleteGrSceneByIds(ids);
    }

    /**
     * 删除签到场次信息
     * 
     * @param id 签到场次ID
     * @return 结果
     */
    @Override
    public int deleteGrSceneById(Long id)
    {
        return grSceneMapper.deleteGrSceneById(id);
    }
}
